# -*- coding: utf-8 -*-
# @Time    : 2020/3/12 10:01
# @Author  : Sunny
# @Site    : 
# @File    : sms.py
# @Software: PyCharm
# @WeChat public address : 程序猿与python之间的秘密

from qcloudsms_py import SmsSingleSender
from qcloudsms_py.httpclient import HTTPError
from django.conf import settings


def sms_send_sign(phone_num, template_id, template_param_list):
    appid = settings.APPID
    appkey = settings.APPKEY
    sms_sign = settings.SMS_SIGN
    ssender = SmsSingleSender(appid, appkey)
    try:
        result = ssender.send_with_param(86, phone_num,
                                         template_id, template_param_list, sign=sms_sign)
    except HTTPError as e:
        result = {'result': 1000, 'errmsg': "网络异常发送失败"}
    except Exception as e:
        print(e)
    return result
